home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ansi
/
txtcap20.zip
/
TEXTCAP.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-12-05
|
41KB
|
864 lines
;----------------------------------------------------------------------
; TEXTCAP is a resident utility which copies a text screen
; to a file. Activate TEXTCAP by pressing Ctrl-F9 or the hot key
; specified by /K<number> on the command line. Help by /?.
; The filename will be SCNxxxxx.TXT. The number part begins with 00000
; and is incremented by 1 each time TEXTCAP is activated.
; ---> Authored originally by Tom Kihlken for PC Magazine in 1987 <---
; ---> Heavily modified by TapirSoft Gisbert W.Selke, 04 Dec 1991 <---
; amongst others a mini-API via INT 16h, ax=4252h..4254h:
; 4252h : installation check, responds with 5242h
; 4253h : removal from memory, responds with segment we used; calling programme
; must de-allocate this segment!
; 4254h : dump text screen now, responds with 5442h
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
BIOS_SEG SEGMENT AT 0040H
ORG 0017H
KB_FLAG DB ? ;BIOS keyboard shift status
BIOS_SEG ENDS
;=======================================================================
CSEG SEGMENT
Assume CS:CSEG, DS:CSEG, ES:CSEG
Org 0080h
CmdLine Label Byte ; pointer to command line
ORG 0100H ; Beginning for .COM programs
START: JMP INITIALIZE ; Initialization code is at end
;-----------------------------------------------------------------------
; Data needed by this program
;-----------------------------------------------------------------------
NROWS Equ 50 ; max number of lines on screen
NCOLS Equ 132 ; max number of columns per line
NBYTES Equ NROWS*NCOLS*2 ; length of screen in bytes
DosCall Equ 21h ; DOS interrupt number
PrintChar Equ 02h ; DOS function 'print char'
PrintString Equ 09h ; DOS function 'print string'
SetVec Equ 2500h ; DOS function 'set interrupt vector'
Keep Equ 3100h ; DOS function 'stay resident'
GetVec Equ 3500h ; DOS function 'get interrupt vector'
FreeMem Equ 49h ; DOS function 'free memory'
Exec Equ 4Bh ; DOS function 'exec'
ExitCode Equ 4Ch ; exit with error code
ChkCode Equ 4252h ; our special installation check
RemoveCode Equ 4253h ; our special request for removal
DumpCode Equ 4254h ; our special request for dumps
InstalledCode Equ 5242h ; footprint 'installed'
Tab Equ 09h ; ASCII tab
CR Equ 0Dh ; carriage return
LF Equ 0Ah ; line feed
CtrlZ Equ 1Ah ; end-of-file mark
CopyRight db CR, 'TEXTCAP 2.0 (c) 1987/91 Ziff Communications Co'
db '/TapirSoft Gisbert W.Selke$', CtrlZ
FileName db 80 Dup (0) ; output path and file name
FileNamePtr dw FileName ; pointer to beginning etc.
HotKey db 43h ; scan code of F9
ShiftMask db 00000100b ; shift mask: any Ctrl key
OldInt09 DD ? ;Old hardware keyboard interrupt vector
OldInt13 DD ? ;Old BIOS disk I/O interrupt vector
OldInt16 DD ? ;Old keyboard input interrupt vector
OldInt21 DD ? ;Old DOS function interrupt vector
CRT_MODE DB ? ;Current video mode
CRT_ROWS DB ? ;Number of lines on screen
CRT_COLS DB ? ;Number of columns on screen, possibly adjusted
CRT_SIZE DW ? ;Actual screen size in bytes (chars+attributes)
ACTIVE_PAGE DB ? ;Number of active video page
WriteFile DB 0 ;If=1, need to write to disk
ACTIVE DB 0 ;Indicates CAPTURE is in use
DOS_Stat DB 0 ;Current DOS function indicator
Busy_flags DB 0 ;Bit masked as follows:
; 1 - DOS function is active
; 2 - BIOS disk I/O is active
;-----------------------------------------------------------------------
; CAPTURE reads the screen and stores it in an internal buffer.
;-----------------------------------------------------------------------
CAPTURE PROC NEAR
Assume DS:CSEG, ES:BIOS_SEG
MOV AH, 0Fh ;Get current video mode
INT 10h
MOV CRT_COLS, AH ;Store number of screen columns
MOV CRT_MODE, AL ;Store video mode
MOV ACTIVE_PAGE, BH ;Store video page
XCHG AH, AL ;Number of columns in AL
XOR AH, AH
CMP AX, NCOLS ;Compare to maximum; may be > 127!
JBE SAVE_COLS ;Skip if we can handle it
MOV AL, NCOLS ;Else use adjusted number
SAVE_COLS: MOV CRT_COLS, AL ;Store in CRT_COLS
PUSH AX ;Save for a sec
MOV DL, 25d ;Default number of lines
MOV AL, CRT_MODE ;Get video mode
CMP AL, 07h ;If 80*25 text, then ok
JE SET_SIZE
MOV AX, 1130h ;Else try to get max line
INT 10h ; ... in DL
INC DL ;Adjust to get # lines
CMP DL, NROWS ;at most NROWS allowed!
JBE SET_SIZE
MOV DL, NROWS
SET_SIZE:
MOV CRT_ROWS, DL ;Jot down # lines
POP AX ;Get back number of columns
MUL DL ;Multiply to get #chars on screen
SHL AX, 1 ;Double for chars+attributes
MOV CRT_SIZE, AX ;This many bytes to write!
MOV AH, 03h ;Cursor pos for this page
MOV BH, ACTIVE_PAGE
INT 10h
PUSH DX ;Save the cursor location
MOV DI,OFFSET BUFFER ;DS:DI points to the buffer
XOR DX,DX ;Start at row 0, column 0
READ_LOOP:
MOV AH, 02h
MOV BH, ACTIVE_PAGE
INT 10h ;Tell BIOS where the cursor is
MOV BH,ACTIVE_PAGE ;Get active page from BIOS data
MOV AH,8 ;BIOS function to read character
INT 10H ;Read the character/attribute
MOV [DI],AX ;Put the character in buffer
INC DI ;Increment the pointer twice
INC DI ;Since we stored a word
INC DL ;Do the next char in same row
CMP DL,DS:CRT_COLS ;At the right border yet?
JNE READ_LOOP ;Do all characters in this row
INC DH ;Move to next row
XOR DL,DL ;Back to left edge (Column 0)
CMP DH,DS:CRT_ROWS ;Done all rows yet?
JNE READ_LOOP ;Loop until whole screen is read